<template>
    <div class="photoinfo-container">
        <h3>{{photoinfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间：{{photoinfo.add_time}}</span>
            <span>点击次数：{{photoinfo.click}}</span>
        </p>
        <hr>
        <div class="thumbs">
            <template>
                <vue-preview :slides="slide1"></vue-preview>
            </template>
        </div>

        <div class="content" v-html="photoinfo.content">

        </div>
        <comment></comment>
    </div>
</template>

<script>
    import comment from '../subcomponents/comment.vue'

    export default {
        data() {
            return {
                id: this.$route.params.id,
                photoinfo: {},
                slide1: []
            }
        },
        methods: {
            getPhotoInfo() {
                this.$http.get('api/getimageInfo/' + this.id).then(res => {
                    if (res.body.status === 0) {
                        this.photoinfo = res.body.message[0]
                    }
                })
            },
            getThumbs() {
                this.$http.get('api/getthumimages/' + this.id).then(res => {
                    if (res.body.status === 0) {
                        res.body.message.forEach(item => {
                            item.w = 1200
                            item.h = 900
                            item.msrc = item.src
                            item.alt = this.id
                            item.title = this.id
                        })
                        this.slide1 = res.body.message
                    }
                })
            }
        },
        created() {
            this.getPhotoInfo()
            this.getThumbs()
        },
        components: {
            comment
        }
    }
</script>

<style  lang="scss">
    .photoinfo-container {
        padding: 3px;
        box-sizing: border-box;

        h3 {
            color: #26A2ff;
            font-size: 15px;
            text-align: center;
            margin: 15px 0;
            line-height: 25px;
        }

        .subtitle {
            display: flex;
            justify-content: space-between;
            font-size: 13px;
        }

        .content {
            font-size: 13px;

        }
        .thumbs{
            display: flex;
            img{
                width: 100px;
                height: 75px;
                display: block;
                box-shadow: 0 0 3px #000;
            }
            figure{
                margin: 10px;
            }
        }
        .my-gallery{
            display: flex;
            width: 100%;
            flex-wrap: wrap;
        }
    }


</style>